package top.eggcode.modules.log.control;

import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.eggcode.common.mvc.Result;
import top.eggcode.common.mvc.ResultWrapper;
import top.eggcode.modules.log.model.*;
import top.eggcode.modules.log.service.*;
import top.eggcode.base.PackBaseController;

/**
 * Title:
 * Description: TODO
 * Date: 2021/5/25 15:13
 *
 * @author JiaQi Ding
 * @version 1.0
 */
@Api(tags = "日志")
@AllArgsConstructor
@RequestMapping("/api/log")
@RestController
public class LogController extends PackBaseController {

    private final ActionLogService actionLogService;

    private final ExceptionLogService exceptionLogService;

    private final FuncLogService funcLogService;

    private final StorageLogService storageLogService;

    private final VisitLogService visitLogService;

    private final LoginLogService loginLogService;

    @PostMapping("/action/save")
    public Result<Boolean> saveToAction(@RequestBody ActionLogEntity log) {
        actionLogService.add(log);
        return ResultWrapper.successful(true);
    }

    @PostMapping("/exception/save")
    public Result<Boolean> saveToException(@RequestBody ExceptionLogEntity log) {
        exceptionLogService.add(log);
        return ResultWrapper.successful(true);
    }

    @PostMapping("/function/save")
    public Result<Boolean> saveToFunction(@RequestBody FuncLogEntity log) {
        funcLogService.add(log);
        return ResultWrapper.successful(true);
    }

    @PostMapping("/login/save")
    public Result<Boolean> saveToLogin(@RequestBody LoginLogEntity log) {
        loginLogService.add(log);
        return ResultWrapper.successful(true);
    }

    @PostMapping("/storage/save")
    public Result<Boolean> saveToStorage(@RequestBody StorageLogEntity log) {
        storageLogService.add(log);
        return ResultWrapper.successful(true);
    }

    @PostMapping("/visit/save")
    public Result<Boolean> saveToVisit(@RequestBody VisitLogEntity log) {
        visitLogService.add(log);
        return ResultWrapper.successful(true);
    }

}
